package com.ruoyi;

import cn.hutool.core.net.NetUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;

import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;

/**
 * 启动程序
 *
 * @author ruoyi
 */

@SpringBootApplication
public class RuoYiApplication {

    private static ServerProperties serverProperties;

    public RuoYiApplication(ServerProperties serverProperties) {
        RuoYiApplication.serverProperties = serverProperties;
    }

    public static void main(String[] args) {

        System.setProperty("spring.devtools.restart.enabled", "false");
        SpringApplication application = new SpringApplication(RuoYiApplication.class);
        application.setApplicationStartup(new BufferingApplicationStartup(2048));
        application.run(args);
        System.out.println("(♥◠‿◠)ﾉﾞ  ruoyi-wms-service启动成功   ლ(´ڡ`ლ)ﾞ");
        ///////////////////////////////////////////////////////////////////////////////////////////

        // ConfigurableApplicationContext context = SpringApplication.run(RuoYiApplication.class, args);
        // ConfigurableApplicationContext context = application.run(args);
        // System.out.println("(♥◠‿◠)ﾉﾞ  ruoyi-wms-service启动成功   ლ(´ڡ`ლ)ﾞ");
        /* ConfigurableApplicationContext context = new SpringApplicationBuilder(WmsApplication.class)
                // Banner.Mode.LOG 打印到日志
                // Banner.Mode.OFF 不打印
                // .bannerMode(Banner.Mode.CONSOLE)
                .bannerMode(Banner.Mode.LOG)
                .run(args);*/
        System.out.println("启动成功，文档地址：http://" + NetUtil.getLocalhost().getHostAddress() + ":" + serverProperties.getPort() + "/v3/api-docs");
        System.out.println("启动成功，接口文档地址：http://" + NetUtil.getLocalhost().getHostAddress() + ":" + serverProperties.getPort() + "/doc.html");
        // 打印JVM gc信息
        System.out.println("Get JDK Default GC for jdk" + System.getProperty("java.version") + " - " + System.getProperty("java.vm.name") + ":");
        // ManagementFactory.getGarbageCollectorMXBeans().forEach(gc -> System.out.println(gc.getName()));
        for (GarbageCollectorMXBean gcBean : ManagementFactory.getGarbageCollectorMXBeans()) {
            System.out.println(gcBean.getName());
        }

    }

}
